import QtQuick 1.0
import com.meego 1.0
import "CommomUtil.js" as CommomUtil
import "Forum.js" as ForumUtil
Page {

    //骑车品牌选择页面
    id:forum_cardBrandPage

    tools: forumToolBar

    orientationLock : PageOrientation.LockPortrait


    property bool loading: dataListModel.status == XmlListModel.Loading

    ForumBackToolBar{
        id:forumToolBar
    }

    Rectangle{
        id:title_rect
        width: 480
        height: 71
        z: 10
        anchors.top: forum_cardBrandPage.top;anchors.left: forum_cardBrandPage.left

        BorderImage {
            id: titlebar_back
            source: "../images/commom/titleBack.png"
            width: title_rect.width; height: title_rect.height
            anchors.fill: title_rect
        }

        Text {
            id: title
           // color: "#f7f0f0"
            color: "white"
            text: "选择品牌"
            horizontalAlignment: Text.AlignHCenter
            font.bold: true; font.pointSize: 16;
            anchors.centerIn: titlebar_back
        }
    }

    Rectangle{
        id:list_rect
        width:parent.width
        height: parent.height-71
        anchors.top: title_rect.bottom
        //  color: "#ebeff9"

        FlickListView {

                   id: card_brand_list
                   anchors.fill: parent

                   model: dataListModel

                   delegate: forumCardBrandList

         }


    }
    XmlListModel{
        id:dataListModel
        source: "http://sp.autohome.com.cn/Nokia/ClubBrandCount.ashx?type=1"
        query: "/Response/Brands/Content/Brand"

         XmlRole { name: "brandId"; query: "Id/string()" }
         XmlRole { name: "brandName"; query: "Name/string()" }
         XmlRole { name: "brandLetter"; query: "BrandLetter/string()" }
         XmlRole { name: "BBSNum"; query: "BBSNum/string()" }
    }
    Component{
        id:forumCardBrandList
        Item{
            id:delegate
            width: 480
            height: 50

           Rectangle{
                id:rect
                color: mouseArea.pressed ? "#3301a1" :"#ebeff9"
                anchors.fill: parent


                 Text{
                        id:brand
                        text: brandName

                        font{
                            family:"Helvetica";pointSize:16;bold:true
                        }

                        anchors.left: parent.left
                        anchors.leftMargin: 30
                        anchors.verticalCenter: parent.verticalCenter

                    }

                Rectangle{
                    width: parent.width;height: 2
                    color:"#cccccc"
                    anchors.bottom: parent.bottom
                }


                MouseArea{
                    id:mouseArea
                    anchors.fill: rect
                    onClicked:{

                       console.log("go to forum:"+brandName);
                        console.log("go to brandId:"+brandId);
                        ForumUtil.setCurrentClubType("1")
                        ForumUtil.setCurrentBrandId(brandId);

                        CommomUtil.openFile("ForumBrandForumList.qml");
                    }

                  }
            }
    }
  }
}
